<div style="width:960px;margin-top: 0px;">
<table cellpadding=0 cellspacing=0 style="width:960px; "><tr>

<td style="width:100%; "  >
<ul id="qm0" class="qmmc">

<?php

	echo '<li><span class="qmdivider qmdividery" ></span></li>';
	$text = '<li><a class="qmparent" href=" '.$CFG->wwwroot.'/">Home</a>';
	$text .= '</li>';
    echo $text;

     
	print_whole_category_list_menu();
	
function print_whole_category_list_menu($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1, $files = true) {
/// Recursive function to print out all the categories in a nice format
/// with or without courses included
    //global $CFG;

 
    if (isset($CFG->max_category_depth) && ($depth >= $CFG->max_category_depth)) {
        return;
    }
    
	if ($category) {
         if ($category->visible or has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM))) {
            print_category_info_menu($category, $depth, $files, $left);
		 } else {
		    return;  // Don't bother printing children of invisible categories
        }

    } else {
        $category->id = "0";
    }
	

    if ($categories = get_child_categories($category->id)) {   // Print all the children recursively
        $countcats = count($categories);
        $count = 0;
        $first = true;
        $last = false;
        foreach ($categories as $cat) {
            $count++;
            if ($count == $countcats) {
                $last = true;
            }
            $up = $first ? false : true;
            $down = $last ? false : true;
            $first = false;

            print_whole_category_list_menu($cat, $displaylist, $parentslist, $depth + 1, $files);
			echo '</ul></li>';
        }
    } 
} 

function print_category_info_menu($category, $depth, $files = false) {
/// Prints the category info in indented fashion
/// This function is only used by print_whole_category_list() above

    //global $CFG;
    $coursecount = count_records('course') <= FRONTPAGECOURSELIMIT;

    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.guest,c.cost,c.currency');
	if ($depth) {
	    echo '<li><span class="qmdivider qmdividerx" ></span></li>';
		if ($category->visible) {
            echo '<li><a class="qmparent" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'.format_string($category->name).'</a>';
		} else {
		   echo '<li><a class="invisiblecategory" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'.format_string($category->name).'</a>';
		}
	} else {
		echo '<li><span class="qmdivider qmdividery" ></span></li>';
		if ($category->visible) {
            echo '<li><a class="qmparent" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'.format_string($category->name).'</a>';
		} else {
		    echo '<li><a class="invisiblecategory" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'.format_string($category->name).'</a>';
		}
	}
	

	if ($files and $coursecount) {
	    echo '<ul>';
        if ($courses && !(isset($CFG->max_category_depth)&& ($depth>=$CFG->max_category_depth - 1))) {
            foreach ($courses as $course) {
			    if ($course->visible) {
				   echo '<li><a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.format_string($course->fullname).'</a></li>';
                } else {
				   echo '<li><a class="invisiblecourse" href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.format_string($course->fullname).'</a></li>';
				}
			}			
        }		
	}	
}
?>

	
<li class="qmclear">&nbsp;</li></ul>
</td></tr></table>

</div>
<!-- Create Menu Settings: (Menu ID, Is Vertical, Show Timer, Hide Timer, On Click ('all', 'main' or 'lev2'), Right to Left, Horizontal Subs, Flush Left, Flush Top) -->
<script type="text/javascript">qm_create(0,false,0,500,false,false,false,false,false);</script>